import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

const viewRouter = new Router({
  routes: [
    {
      path: '/',
      component: ()=> import('views_app/instructions.vue'),
      meta: {
        title: '超级节点细则'
      }
    },
    {
      path: '/superPointUser',
      component: ()=> import('views_app/superPointUser.vue'),
      meta: {
        title: '超级节点'
      }
    },
    {
      path: '/profitDetail',
      component: ()=> import('views_app/profitDetail.vue'),
      meta: {
        title: '超级节点收益明细'
      }
    },
    {
      path: '/minerList',
      component: ()=> import('views_app/minerList.vue'),
      meta: {
        title: '邀请矿工明细'
      }
    },
    {
      path: '/minerProfitDetail',
      component: ()=> import('views_app/minerProfitDetail.vue'),
      meta: {
        title: '收益明细'
      }
    },
    {
      path: '/minerProfitDetailNew',
      component: ()=> import('views_app/minerProfitDetailNew.vue'),
      meta: {
        title: '矿工收益明细'
      }
    },
    {
      path: '/minerIdCheck',
      component: ()=> import('views_app/minerIdCheck.vue'),
      meta: {
        title: '矿工审核'
      }
    },
    {
      path: '/invitationResult',
      component: ()=> import('views_app/invitationResult.vue'),
      meta: {
        title: '邀请矿工'
      }
    },
  ]
})

viewRouter.beforeEach((to, from, next) => {
  if (to.meta.title) {
    document.title = to.meta.title
  }
  let uid = to.query.uid || localStorage.getItem('uid')
  let token = to.query.token || localStorage.getItem('token')
  next()
  setTimeout(()=>{
    localStorage.setItem('uid', uid)
    localStorage.setItem('token', token)
  },40)
})


export default viewRouter

